

var facturacion = {
		
		init : function(){
			
			$.loadModal('Buscando telefono....');	
			

			$("#txtTelefono").keypress(function(e){

				// NOTA: Backspace = 8, Enter = 13, '0' = 48, '9' = 57
		        var key = e.which;
		        if (!(key <= 13 || (key >= 48 && key <= 57))) {
		        	e.preventDefault();
		        	$("#errorTelefono").css("display","inline");

		        }
		        else{
		        	
		        	$("#errorTelefono").css("display","none");
		        }

			});
			
			$("#btnSearch").click(function(){
				
				var phone = $("#txtTelefono");
				
				if(validateFieldBlank(phone.val())){
					
					alert("Ingresar Telefono");
					phone.focus();
					return false;
				}
				
				$.loadModal.start();
				
				
				$.post("detalleFactura.jsp",{phone:phone.val()},function(data){
					
					$.loadModal.stop();
					
					var win =  new Ext.Window({
						title:"Factura",
						width:800,
						height:700,
						minimizable:true,
						maximizable:true
						
					});
					
				
					win.show();
					$("div.x-window-mr div div").html(data);
					
					
				},"html");
				
				//$("body").load('detalleFactura.jsp');
				//facturacion.searchPhone(phone.val());
			
			 });
		},
		
		searchPhone : function(phone){
			
			
		}
		
};

$(document).ready(facturacion.init);